import PublicService from '@src/services/PublicService'
import { IReq, IRes, INext } from "@src/routes/common/types";
import { resExample } from '@src/services/common/responseData';

class PublicController {
    /**
 * 发送验证码
 * @param req 
 * @param res 
 * @param next 
 */
    code = async (req: IReq, res: IRes, next: INext) => {
        try {
            const { body } = req;
            const user = await PublicService.code(body);
            res.status(user.code).json(user);
        } catch (error) {
            next(error);
        }
    }
    /**
     * 上传图片
     */
    upload = async (req: IReq, res: IRes, next: INext) => {
        try {
            const { file } = req;
            const user = await PublicService.upload(file!);
            res.status(user.code).json(user);
        } catch (error) {
            next(error);
        }

    }
}

export default new PublicController();
